local gameObjs = pp.gameObjs

achieveCfg = achieveCfg or {}


achieveCfg = {

    calc_FinishTimes = function(item)
        if item.interval then
            return math.floor(item.userdata.triggerTimes / item.interval)
        end
    end,
    
    calc_appendant = function(item)
        return (item.userdata.getTimes+1)*item.interval
    end,

	FinishLevel = {
		nameImg = "common/achieve/chuangguandr.png",
		descText = "顺利通过第%d关",
        bNeedAppendant = true, 
        
		interval = 3,

		reward = {
            {gameObjRef = gameObjs.coin,     cnt = function(fshTimes) return 50*fshTimes end },
            {gameObjRef = gameObjs.yuheng,  cnt = function(fshTimes) return 1 end},
            {gameObjRef = gameObjs.fenji,   cnt = function(fshTimes) return 2*(fshTimes+1) end},
		},	

		userdata = {triggerTimes = 0, getTimes = 0}
	},

	BossKiller = {
		nameImg = "common/achieve/bosskiller.png",
		descText = "击败第%d关的Boss",

		interval = 5,

		reward = {
			{gameObjRef = gameObjs.coin, 	cnt = function(fshTimes) return 50*fshTimes end	},
			{gameObjRef = gameObjs.yuheng, 	cnt = function(fshTimes) return 1 end},
			{gameObjRef = gameObjs.fenji, 	cnt = function(fshTimes) return 2*(fshTimes+1) end},
		},	

		userdata = {triggerTimes = 0, getTimes = 0}
	},

	Lottery = {
		nameImg = "common/achieve/bosskiller.png",
		descText = "抽奖达到2次",

		interval = 2,

		reward = {
			{gameObjRef = gameObjs.coin, 	cnt = function(fshTimes) return 50*fshTimes end	},
			{gameObjRef = gameObjs.yuheng, 	cnt = function(fshTimes) return 1 end},
			{gameObjRef = gameObjs.fenji, 	cnt = function(fshTimes) return 2*(fshTimes+1) end},
		},	

		userdata = {triggerTimes = 0, getTimes = 0}
	},

	Intensify = {
		nameImg = "common/achieve/qiangh.png",
		descText = "强化达到2次",

		interval = 3,

		reward = {
			{gameObjRef = gameObjs.coin, 	cnt = function(fshTimes) return 50*fshTimes end	},
			{gameObjRef = gameObjs.yuheng, 	cnt = function(fshTimes) return 1 end},
			{gameObjRef = gameObjs.fenji, 	cnt = function(fshTimes) return 2*(fshTimes+1) end},
		},	

		userdata = {triggerTimes = 0, getTimes = 0}
	},

	AllStars = {
		nameImg = "common/achieve/xingyuncj.png",
		descText = "三星通关达%d关",

		interval = 2,

		reward = {
			{gameObjRef = gameObjs.coin, 	cnt = function(fshTimes) return 50*fshTimes end	},
			{gameObjRef = gameObjs.yuheng, 	cnt = function(fshTimes) return 1 end},
			{gameObjRef = gameObjs.fenji, 	cnt = function(fshTimes) return 2*(fshTimes+1) end},
		},	

		userdata = {triggerTimes = 0, getTimes = 0}
	},

	Fuhuo = {
		nameImg = "common/achieve/yuandifh.png",
		descText = "复活1次",

		reward = {
			{gameObjRef = gameObjs.coin, 	cnt = 10},
		},
		userdata = {achieved = false}
	},

	Fenji = {
		nameImg = "common/achieve/shiyongfj.png",
		descText = "使用焚寂道具",

		reward = {
			{gameObjRef = gameObjs.coin, 	cnt = 20},
		},
		userdata = {achieved = false}
	},

	Yuheng = {
		nameImg = "common/achieve/shiyongyh.png",
		descText = "使用玉衡道具",

		reward = {
			{gameObjRef = gameObjs.coin, 	cnt = 30},
		},
		userdata = {achieved = false}
	},

	Coin = {
		nameImg = "common/achieve/huoqujb.png",
		descText = "成功获取金币",

		reward = {
			{gameObjRef = gameObjs.coin, 	cnt = 50},
		},
		userdata = {achieved = false}
	},

	Tili = {
		nameImg = "common/achieve/tilicp.png",
		descText = "成功补满体力",

		reward = {
			{gameObjRef = gameObjs.coin, 	cnt = 50},
		},
		userdata = {achieved = false}
	},

	Changwan = {
		nameImg = "common/achieve/jingqcw.png",
		descText = "开通畅玩礼包",

		reward = {
			{gameObjRef = gameObjs.coin, 	cnt = 50},
		},
		userdata = {achieved = false}
	},


	orderInList = {
		"FinishLevel",
		"BossKiller",
		"Lottery",
		"Intensify",
		"AllStars",
		"Fuhuo",
		"Fenji",
		"Yuheng",
		"Coin",
		"Tili",
		"Changwan",
	},

	calc_progress = function(item, triggerTimes)
		if item.interval then
			local extraTimes = triggerTimes%item.interval
			local finishTimes = (triggerTimes - extraTimes)/item.interval
			return extraTimes, item.interval, finishTimes
		else
			if item.userdata.achieved then
				return 1, 1
			else
				return 0, 1
			end
		end
	end
}